// 工作量统计中心
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';

enum Api {
  listPutInfoEffect = '/screeing/artDevanning/list', //获取列表
  save = '/screeing/artDevanning/add', //新增
  edit = '/screeing/artDevanning/edit', //编辑
  getIntoById = '/screeing/artDevanning/queryById', //获取编辑数据
  deletePutInfoEffect = '/screeing/artDevanning/delete',
  deleteBatch = '/screeing/artDevanning/deleteBatch',
}

/**
 * 列表接口
 * @param params
 */
export const listPutInfoEffect = (params) => defHttp.get({ url: Api.listPutInfoEffect, params });
/**
 * 获取编辑数据
 * @param params
 */
export const getIntoById = (params) => defHttp.get({ url: Api.getIntoById, params });

/**
 * 编辑保存
 * @param params
 */
export const savePutInfoEffect = (params, isUpdate) => {
  const url = isUpdate ? Api.edit : Api.save;
  console.log(`output->url,params`, url, params);
  return defHttp.post({ url: url, params });
};
/**
 * 删除
 */
export const deletePutInfoEffect = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.deletePutInfoEffect, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};
/**
 * 批量删除
 * @param params
 */
export const batchDeletePutInfoEffect = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
};
